<?php

error_reporting(E_ERROR | E_WARNING | E_PARSE);

function printRegisterForm() {
?>
<form method="post" action="index.php?content=reg&reg=true">
	<fieldset>	
		<p><label for="01">Name</label> <input id="01" name="name" type="text"></p>
		<p><label for="02">Vorname</label> <input id="02" name="vorname" type="text"></p>
		<p><label for="03">E-Mail</label> <input id="03" name="email" type="text"></p>
		<p><label>Geburtsdatum</label>	  	
			<select name="day"><?php
				for($i = 01; $i<= 31; $i++){
					if($i<10){
						echo "<option value=\"0$i\">0".$i."</option>";
					}else{
						echo "<option value=\"$i\">".$i."</option>";
					}	
				}
			?>	
	  		</select>
	  		<select name="month"><?php
				for($i = 01; $i<= 12; $i++){
					if($i<10){
						echo "<option value=\"0$i\">0".$i."</option>";
					}else{
						echo "<option value=\"$i\">".$i."</option>";
					}	
				}
			?>
	  		</select>
	  		<select name="year"><?php
				for($i = 1950; $i<= 2012-14; $i++){
					echo "<option value=\"$i\">".$i."</option>";	
				}
			?>
	  		</select>
	  	</p>
		<p><label for="05">Stra&szlig;e</label> <input id="05" name="street" type="text"></p>
		<p><label for="06">Hausnummer</label> <input id="06" name="number" type="text"></p>
		<p><label for="07">Postleitzahl</label> <input id="07" name="plz" type="text"></p>
		<p><label for="08">Ort</label> <input id="08" name="ort" type="text"></p>
		<p><label for="09">Telefon</label> <input id="09" name="tel" type="text"></p>
		<p><label for="10">Passwort</label> <input id="10" name="passwort" type="password"></p>
		<p><label for="11">Passwort wiederholen</label> <input id="11" name="passwort2" type="password"></p>
		<p><input type="submit" name="register" value="Jetzt registrieren"/></p>
	</fieldset>
</form>
<?php
}
?>
<?php
function printLoginForm() {
?>

<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
	<fieldset id="login">
		<!-- <label for="email">E-Mail:</label> -->
		<input id="email" name="email" type="text" onfocus="if(this.value == 'E-Mail') {this.value = '';}" onblur="if(this.value == '') {this.value = 'E-Mail';}" value="E-Mail" />
		<!-- <label for="passwort">Passwort:</label> -->
		<input id="password" name="passwort" type="password" onfocus="if(this.value == 'passwort') {this.value = '';}" onblur="if(this.value == '') {this.value = 'passwort';}" value="passwort" />
		<input type="submit" name="login" value="Login" />
	</fieldset>
</form>
<?php
}
?>
<?php
function printShowForm() {
	$email = $_COOKIE["email"];
	$sql = "SELECT * FROM user WHERE email='".mysql_real_escape_string($email)."'";
	$result = mysql_query($sql);
	$row = mysql_fetch_row($result);
	$gebdate = $row[4];
	list ($year, $month, $day) = split('[-.-]', $gebdate);
?>
<form method="post">
	<fieldset>	
		<p><label for="01">Name</label> <input disabled="disabled" id="01" name="name" type="text" value="<?php echo $row[1] ?>"></p>
		<p><label for="02">Vorname</label> <input disabled="disabled" id="02" name="vorname" type="text" value="<?php echo $row[2] ?>"></p>
		<p><label for="03">E-Mail</label> <input disabled="disabled" id="03" name="email" type="text" value="<?php echo $row[3] ?>"></p>
		<p><label>Geburtsdatum</label>	  	
			<select name="day" disabled="disabled">
				<option value="<?php echo $day ?>"><?php echo $day ?></option> 
	  		</select>
	  		<select name="month" disabled="disabled">
	  			<option value="<?php echo $month ?>"><?php echo $month ?></option> 
	  		</select>
	  		<select name="year" disabled="disabled">
	  			<option value="<?php echo $year ?>"><?php echo $year ?></option>
	  		</select>
		</p>
		<p><label for="04">Stra&szlig;e</label> <input disabled="disabled" id="04" name="street" type="text" value="<?php echo $row[7] ?>"></p>
		<p><label for="05">Hausnummer</label> <input disabled="disabled" id="05" name="number" type="text" value="<?php echo $row[8] ?>"></p>
		<p><label for="06">Postleitzahl</label> <input disabled="disabled" id="06" name="plz" type="text" value="<?php echo $row[5] ?>"></p>
		<p><label for="07">Ort</label> <input disabled="disabled" id="07" name="ort" type="text" value="<?php echo $row[6] ?>"></p>
		<p><label for="08">Telefon</label> <input disabled="disabled" id="08" name="tel" type="text" value="<?php echo $row[9] ?>"></p>
		<p><input type="submit" name="change" value="Daten &auml;ndern" /></p>
	</fieldset>
</form>
<?php
}
?>
<?php
function printEditForm() {
	$email = $_COOKIE["email"];
	$sql = "SELECT * FROM user WHERE email='".mysql_real_escape_string($email)."'";
	$result = mysql_query($sql);
	$row = mysql_fetch_row($result);
	$gebdate = $row[4];
	list ($year, $month, $day) = split('[-.-]', $gebdate);
?>
<form method="post">
	<fieldset>	
		<p><label for="01">Name</label> <input id="01" name="name" type="text" value="<?php echo $row[1] ?>"></p>
		<p><label for="02">Vorname</label> <input id="02" name="vorname" type="text" value="<?php echo $row[2] ?>"></p>
		<p><label for="03">E-Mail</label> <input id="03" name="email" type="text" value="<?php echo $row[3] ?>"></p>
		<p><label>Geburtsdatum</label>	  	
			<select name="day"><?php
				for($i = 01; $i<= 31; $i++){
					if($i == $day){
						echo "<option value=\"$day\" selected>".$day."</option>";
					}elseif($i<10){
						echo "<option value=\"0$i\">0".$i."</option>";
					}else{
						echo "<option value=\"$i\">".$i."</option>";
					}	
				}
			?>	
	  		</select>
	  		<select name="month"><?php
				for($i = 01; $i<= 12; $i++){
					if($i == $month){
						echo "<option value=\"$month\" selected>".$month."</option>";
					}elseif($i<10){
						echo "<option value=\"0$i\">0".$i."</option>";
					}else{
						echo "<option value=\"$i\">".$i."</option>";
					}	
				}
			?>
	  		</select>
	  		<select name="year"><?php
				for($i = 1950; $i<= 2012-14; $i++){
					if($i == $year){
						echo "<option value=\"$year\"selected>".$year."</option>";
					}else{	
						echo "<option value=\"$i\">".$i."</option>";
					}	
				}
			?>
	  		</select>
	  	</p>
		<p><label for="04">Stra&szlig;e</label> <input id="04" name="street" type="text" value="<?php echo $row[7] ?>"></p>
		<p><label for="05">Hausnummer</label> <input id="05" name="number" type="text" value="<?php echo $row[8] ?>"></p>
		<p><label for="06">Postleitzahl</label> <input id="06" name="plz" type="text" value="<?php echo $row[5] ?>"></p>
		<p><label for="07">Ort</label> <input id="07" name="ort" type="text" value="<?php echo $row[6] ?>"></p>
		<p><label for="08">Telefon</label> <input id="08" name="tel" type="text" value="<?php echo $row[9] ?>"></p>
		<p><label for="09">Passwort</label> <input id="09" name="passwort" type="password" value="<?php echo $row[10] ?>"></p>
		<p><label for="10">Passwort wiederholen</label> <input id="10" name="passwort2" type="password" value="<?php echo $row[10] ?>"></p>
		<p><input type="submit" name="change" value="Änderungen speichern" /></p>
	</fieldset>
</form>
<?php
}
?>
<?php
function printEntryForm(){
?>	
    <form id="entryForm" action="index.php?content=entry" method="post">
    	
		<input type="hidden" name="formname" value="entryForm">
		
		<p><label for="datepicker">Datum:</label><input id="datepicker" class="datepicker" type="text" name="date"/><label for="datepicker"><img src="img/datepicker.png" alt="Datum auswählen" class="labelimg"/></label></p>
		
		<p>
			<label for="time">Uhrzeit:</label>
			<select name="hours">
				<?php
				
					for($i = 0 ; $i < 24 ; $i++){
					
						if( $i < 10 ){
							
							$value = '0'.$i;
							
						}
						else{
							
							$value = $i;
							
						}
						
						echo '<option value="'.$value.'"';
						if($value == '08'){echo 'selected';}
						echo '>'.$value.'</option>';
					}
				?>
		  	</select>
		  	<select name="minutes">
		  		<?php
					$i = 0;
					while($i < 60){
					
											
							if( $i < 10 ){
								
								$value = '0'.$i;
								
							}
							else{
								
								$value = $i;
								
							}
							
							$i = $i + 5;

						
						echo '<option value="'.$value.'">'.$value.'</option>';
					}
				?>
		  	</select>
		</p>
    	
      	<p><label for="origin">Startort:</label><input id="origin" type="text" name="origin"/></p>
      	
      	<p class="via"><label for="via">Via:</label><input id="via" type="hidden" name="via" value="-"/><input type="button" name="delete" class="delete" value="-"></p>
      	
      	<p id="insertvia"><img src="img/plus.png" alt="Zwischenstop hinzufügen"/>&nbsp;Zwischenstation hinzufügen.</p>
      	
      	<script type="text/javascript">
				$(document).ready(function() {
					
					$('#insertvia').click(function(){
						
						var row = $('#via').parent();
						
						$(row).css("display", "inline");
						
						$('#via').prop("type","text");
						$('#via').removeAttr("value");
						
						$('#insertvia').css("display", "none");
						
						
					});
						
					$('.delete').click(function() {
						// Gibt die Anzahl der Reihen an, indem es die Anzahl der ELemente der Klasse addfieldrow zählt.
						var rows = $('.via').length;
						if(rows = 1){
							$(this).parent().css("display", "none");
							$('#insertvia').css("display", "inline");
						}
					});
				});
		</script>
      
	  <p><label for="destination">Zielort:</label><input id="destination" type="text" name="destination"/></p>
	  
	  <p><label for="driversLicence">Führerscheinnummer:</label><input id="driversLicence" type="text" name="driversLicence"/></p>
	  
	  <p>
	  	<label for="seats">Plätze:</label>
	  	<select name="seats">
	  		<option value="1">1</option>
	  		<option value="2">2</option>
	  		<option value="3">3</option>
	  		<option value="4">4</option>
	  		<option value="5">5</option>
	  		<option value="6">6</option>
	  		<option value="7">7</option>
	  		<option value="8">8</option>
	  		<option value="9">9</option>
	  	</select>
	  </p>
	  
	  <p>
	  	<label for="smoking">Rauchen:</label>
	  	<select name="smoking">
	  		<option value="no">Nein</option>
	  		<option value="yes">Ja</option>
	  	</select>
	  </p>
	  
	  <input type="submit" name="submit" value="Fahrt eintragen" />
      
    </form>
<?php	
}
?>
<?php
function printSearchForm(){
?>	
    <form id="searchForm" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>?content=result" method="post">
      <p><label for="datepicker2">Datum:</label><input id="datepicker2" class="datepicker" type="text" name="date2"/><label for="datepicker2"><img src="img/datepicker.png" alt="Datum auswählen" class="labelimg"/></label></p>
      <p><label for="sStart">Startort:</label><input id="sStart" type="text" name="from" /></p>
      <p><label for="sDestination">Zielort:</label><input id="sDestination" type="text" name="to" /></p>
      <input type="submit" name="submit" value="Jetzt suchen" />
    </form>
<?php	
}
?>
<?php
function printMitfahrForm(){
?>
	<form id="mitfahrForm" action"<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>?content=lift" method="post">
		<p>
	  	<label for="seats2">Plätze:</label>
	  	<select name="seats2">
	  		<option value="1">1</option>
	  		<option value="2">2</option>
	  		<option value="3">3</option>
	  		<option value="4">4</option>
	  		<option value="5">5</option>
	  		<option value="6">6</option>
	  		<option value="7">7</option>
	  		<option value="8">8</option>
	  		<option value="9">9</option>
	  	</select>
	  </p>
		<p><label for="eingabe">Nachricht:</label><textarea id="seingabe" type = "text" cols="40" rows="5" name="seingabe"></textarea></p>
		<input type="submit" name="submit" value="Anfrage abschicken"/>	
	</form>

<?php
}
?>